import {onBeforeUnmount, onMounted, reactive} from "vue";

export default function () {
    let coord = reactive({
        x: 0,
        y: 0
    });

    function displayCoord(e) {
        coord.x = e.x;
        coord.y = e.y;
    }

    onMounted(() => {
        window.addEventListener('mousemove', displayCoord);
    });

    onBeforeUnmount(() => {
        window.removeEventListener('mousemove', displayCoord)
    });

    return coord;
}